<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
   

    <input class="user" type="text">
    <br>
    <input class="pwd" type="text">
    <br>
    <button>注册</button>


    <script src="tools.js"></script>

    <script>
         let oUser = document.querySelector('.user');
         let oPwd = document.querySelector('.pwd');
         let oBtn = document.querySelector('button')

         oBtn.onclick = function(){
            let user = oUser.value;
            let pwd = oPwd.value;

            let res = getCookie('YYDS_' + user);
            if(res){
                alert('用户名重复')
            }else{
                setCookie('YYDS_' + user, pwd );
                location.href = './02login.html' ;
            }
         }
    </script>
</body>
</html>